require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsFirstPayGiftHandler ={};
local this = RedDotsFirstPayGiftHandler;

function RedDotsFirstPayGiftHandler.init()
    CloseEvent(Config.EventType.Fresh_FirstPayGiftRedDot,this.update);
    ListenEvent(Config.EventType.Fresh_FirstPayGiftRedDot,this.update);
    CloseEvent(Config.EventType.Fresh_Active,this.update);
    ListenEvent(Config.EventType.Fresh_Active,this.update);
    return this;
end
-- 获取红点状态
function RedDotsFirstPayGiftHandler.getFlag(...)
    local type={...}
    local severData, tableData = logicMgr.CostManager.getCostData(logicMgr.CostManager._FIRSTPAYGIFTID);
    local accumulateState=logicMgr.ActiveManager.getActiveData(logicMgr.CostManager._ACCUMULATEPAYID)
    local flag=Config.RedDotsFlagState.None;
    if type[2]==1 then
        if severData ~= nil and severData.receiveState == 1 then
            flag= Config.RedDotsFlagState.Needful;
        end
    elseif type[2]==2 then
        if accumulateState ~= nil and accumulateState==1 then
            flag= Config.RedDotsFlagState.Needful;
        end
    else
        if (severData ~= nil and severData.receiveState == 1) or (accumulateState ~= nil and accumulateState==1) then
            flag= Config.RedDotsFlagState.Needful;
        end
    end
    return flag
end


function RedDotsFirstPayGiftHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.FirstPayGift);
end